Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use warnings.warn instead of logger.warning #321

Merged
merged 10 commits into from
May 29, 2019
Merged

Use warnings.warn instead of logger.warning #321

merged 10 commits into from
May 29, 2019

Conversation

mpenkov
Copy link
Collaborator

@mpenkov mpenkov commented May 28, 2019

Fix #319

@@ -382,7 +382,7 @@ def open(

def smart_open(uri, mode="rb", **kw):
"""Deprecated, use smart_open.open instead."""
logger.warning('this function is deprecated, use smart_open.open instead')
warnings.warn('this function is deprecated, use smart_open.open instead')
Copy link
Owner

@piskvorky piskvorky May 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link to the smart_open => open migration instructions here? This "use smart_open.open instead" is a massive ask, unless it's a 1:1 transparent swap without any potential issues (which I don't think it is).

Let's inform the user more clearly what are the expected tradeoffs / benefits of such change, and what their migration and potential incompatibilities look like.

Copy link
Owner

@piskvorky piskvorky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

Submitting a few minor rewording suggestions.

README.rst Outdated Show resolved Hide resolved
README.rst Outdated
Since 1.8.1, there is a `smart_open.open` function that replaces `smart_open.smart_open`.
The new function offers several advantages over the old one:

- 100% compatible with the built-in open function (aka io.open): it accepts all
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 100% compatible with the built-in open function (aka io.open): it accepts all
- 100% compatible with the built-in `open` function (aka `io.open`): it accepts all

README.rst Outdated

- 100% compatible with the built-in open function (aka io.open): it accepts all
the parameters that the built-in open accepts.
- Default open mode is now "r", the same as for the built-in open
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Default open mode is now "r", the same as for the built-in open
- The default `smart_open.open` mode is now "r", the same as for the built-in `open` (`smart_open.smart_open` default used to be "rb").

README.rst Outdated
- Default open mode is now "r", the same as for the built-in open
- Fully documented keyword parameters (try `help("smart_open.open")`)

These instructions will help you migrate to the new function painlessly.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These instructions will help you migrate to the new function painlessly.
The instructions below will help you migrate to the new function painlessly.


warnings.warn(
'This function is deprecated, use smart_open.open instead. '
'See the migration notes for details: %s' % _MIGRATION_NOTES_URL
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'See the migration notes for details: %s' % _MIGRATION_NOTES_URL
'See the migration instructions: %s' % _MIGRATION_NOTES_URL

mpenkov and others added 2 commits May 29, 2019 21:06
Co-Authored-By: Radim Řehůřek <me@radimrehurek.com>
@mpenkov mpenkov merged commit 2a5b16d into piskvorky:master May 29, 2019
@mpenkov mpenkov deleted the warn branch May 29, 2019 14:17
Copy link
Owner

@piskvorky piskvorky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpenkov something went wrong with your edits.

annual/monthly_rain/2012.monthly_rain.nc 13


Migrating to the New `open` Function
Copy link
Owner

@piskvorky piskvorky May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpenkov what happened here? I remember commenting on this line in a review, and you fixing it. But now it's back in the master README.


- `profile_name`

**The `profile_name` parameter has been removed.**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is wrong with the backticks. They have no effect in this section (look like normal text when rendered), and this line actually renders them as literal backticks:

Screen Shot 2019-05-31 at 09 58 03

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's just the way github renders RST. I don't know what we can do about that.

Copy link
Owner

@piskvorky piskvorky May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaah, this is RST, not Markdown! That explains it.

Literal blocks in RST use double-backticks IIRC, not single-backtick.

Do we need to use RST though? MD easier? Or is it something to do with PyPI relying on RST…

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's because of PyPI

See `help("smart_open.open")` for the full list of acceptable parameter names,
or view the help online `here <https://github.com/RaRe-Technologies/smart_open/blob/master/help.txt>`__.

If you pass an invalid parameter names, the `open` function will warn you about it.
Copy link
Owner

@piskvorky piskvorky May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:

If you pass an invalid parameter name, the `open` function will warn you about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WARNING this function is deprecated, use smart_open.open instead
2 participants